package com.demo.security.access.intercept.aopalliance;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.demo.security.access.LogicMetadataSource;
import com.demo.security.access.intercept.AbstractLogicInterceptor;
import com.demo.security.access.intercept.InterceptorLogicToken;
/**
 * 基于方法的 访问逻辑拦截器
 * 对方法调用进行拦截，根据逻辑属性处理。
 * 
 * @author ryuu.kk
 *
 */
public class MethodAccessLogicInterceptor extends AbstractLogicInterceptor implements MethodInterceptor {
	/**
	 * 逻辑调用的元数据
	 */
	private LogicMetadataSource logicMetadataSource;
	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		InterceptorLogicToken invokeToken = super.beforeInvocation(invocation);
		
		Object result = invocation.proceed();
		
		return super.afterInvocation(invokeToken, result);
	}

	@Override
	public Class<?> getLogicObjectClass() {
		return MethodInvocation.class;
	}

	@Override
	public LogicMetadataSource obtainLogicMetadataSource() {
		return this.logicMetadataSource;
	}

	public void setLogicMetadataSource(LogicMetadataSource logicMetadataSource) {
		this.logicMetadataSource = logicMetadataSource;
	}
}
